home *** CD-ROM | disk | FTP | other *** search
/ Gamers Delight 2 / Gamers Delight 2.iso / Aminet / game / board / UChessSrc.lha / gnuchess.h < prev    next >
C/C++ Source or Header  |  1994-07-28  |  26KB  |  908 lines

  1. /*#define LONGINTS 1*/
  2. #define AGING 1
  3. #define NODITHER 1
  4. #define INTSIZE short
  5. /*#define LONGINTS2 1*/
  6. #ifdef LONGINTS
  7. #define INTSIZE2 long
  8. #else
  9. #define INTSIZE2 short
  10. #endif
  11.  
  12.  
  13. #ifdef _M68040
  14. #define VERSTRING "UChess v2.89L(040)"
  15. #define AVSTR "$VER: UChess 2.89L [040] (29.07.94)"
  16. #else
  17. #ifndef TINYCHESS
  18. #define VERSTRING "UChess v2.89(020)"
  19. #define AVSTR "$VER: UChess 2.89 [020] (29.07.94)"
  20. #else
  21. #define VERSTRING "UChess v2.89T(020)"
  22. #define AVSTR "$VER: UChess 2.89T [020] (29.07.94)"
  23. #endif
  24. #endif
  25.  
  26.  
  27. #define ARGSZ long
  28.  
  29. #define REG register
  30.  
  31. /* 
  32.    To fix it as a tool for pgm use, modify the routine
  33.    InputCommand() in dspcom.c and OutputMove() in nondsp.c 
  34.    modify main.c to setup screen, etc,
  35.    modify inline statement below,
  36.    Modify SelectLevel in nondsp.c so that it does not use scanf
  37.    in dspcom.c, ElapsedTime function is where you cut short
  38.    any thinking on human players time.  Around the FIONREAD
  39.    area, you need a loop for looking for the intuition events
  40.    and stop the thinking short if that happens
  41.  
  42.    Modify PromptForMove in nondsp.c, actaully may not be needed at all
  43.  
  44.    */
  45.  
  46. /*
  47.  * gnuchess.h - Header file for GNU CHESS
  48.  *
  49.  * Copyright (c) 1988,1989,1990 John Stanback
  50.  * Copyright (c) 1992 Free Software Foundation
  51.  *
  52.  * This file is part of GNU CHESS.
  53.  *
  54.  * GNU Chess is free software; you can redistribute it and/or modify
  55.  * it under the terms of the GNU General Public License as published by
  56.  * the Free Software Foundation; either version 2, or (at your option)
  57.  * any later version.
  58.  *
  59.  * GNU Chess is distributed in the hope that it will be useful,
  60.  * but WITHOUT ANY WARRANTY; without even the implied warranty of
  61.  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
  62.  * GNU General Public License for more details.
  63.  *
  64.  * You should have received a copy of the GNU General Public License
  65.  * along with GNU Chess; see the file COPYING.  If not, write to
  66.  * the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA.
  67.  */
  68.  
  69. /*
  70.  
  71.  On an Amiga 4000, Gnuchess 4.0 gets from  80,000(short), 100,000 (long)
  72.  nodes/sec on MoveList, and 3000(s)-3700(l) Nodes/sec on Eval Speed 
  73.  
  74.  On a SunStation (netcom), Gnuchess 4.0 gets from 100,000 to 133,300 nodes/sec on
  75.  MoveList, and 3700 Nodes/sec on Eval Speed 
  76.  
  77. */
  78.  
  79.  
  80. #if !defined(__STDC__) || !defined(MSDOS)
  81. #define const
  82. #endif
  83.  
  84. #ifndef __GNUC__
  85. #define inline __inline
  86. #endif
  87.  
  88. #include <stdio.h>
  89.  
  90. typedef unsigned char    UCHAR;        /* unsigned 8-bit quantity */
  91. typedef short tshort;
  92. typedef unsigned short utshort;
  93. #ifdef USEINT
  94. typedef  int SHORT;
  95. typedef  unsigned int UTSHORT;
  96. #else
  97. typedef unsigned short UTSHORT;
  98. //typedef short SHORT;
  99. #endif
  100.  
  101.  
  102. #ifdef AMIGA
  103. #undef printf
  104. #define printf NULLY
  105. #undef stdin
  106. #undef stdout
  107. #undef stderr
  108. #define stdin NULLYIN
  109. #define stdout NULLYOUT
  110. #define stderr NULLYERR
  111. #undef scanf
  112. #define scanf NULLYSCANF
  113. #endif
  114.  
  115. #define SEEK_SET 0
  116. #define SEEK_END 2
  117. #ifdef DEBUG
  118. void
  119. ShowDBLine (char *, INTSIZE int, INTSIZE int,
  120.         INTSIZE int, INTSIZE int, INTSIZE int,
  121.         INTSIZE unsigned int *);
  122.      extern FILE *debugfd;
  123.      extern INTSIZE int debuglevel;
  124.  
  125. #endif /* DEBUG */
  126.  
  127. #include <ctype.h>
  128.  
  129. #ifdef AMIGA
  130. #define __USE_SYSBASE
  131. #include <exec/types.h>
  132. #include <dos/dos.h>
  133. #include <proto/exec.h>
  134. #endif
  135.  
  136.  
  137. extern long int GenCnt;
  138.  
  139. extern int GlobalTgtDepth;
  140. extern int TCadd;
  141. extern int mycnt3;
  142. extern int globalmessage_valid;
  143. extern struct IntuiMessage __aligned globalmessage;
  144. extern char __far HintString[80];
  145. extern char __far MateString[40];
  146. extern int AmigaStarted;
  147. extern int Mate;
  148. extern int DrawnGame;
  149.  
  150. void
  151.  TestSpeed (void (*f) (INTSIZE int side, INTSIZE int ply), unsigned j);
  152. void
  153.  TestPSpeed (INTSIZE int (*f) (INTSIZE int side), unsigned j);
  154.  
  155. void GetEditText(char *,int *);
  156. void CloseAmigaEditWindow(void);
  157. int OpenAmigaEditWindow(void);
  158.  
  159. unsigned int urand (void);
  160. void gsrand (unsigned int seed);
  161.  
  162. #ifdef AMIGA
  163. void __regargs MoveMem(void *,void *,ULONG);
  164. void __regargs MoveMem128(void *,void *);
  165. void __regargs ClearMem(void *,ULONG);
  166. #endif
  167. int myfgets(char *,int ,BPTR);
  168. int DoResign(void);
  169. void EnableMoveNow(void);
  170. void DisableMoveNow(void);
  171. void UpdateClocks (void);
  172. int LoadFullBitMap(void);
  173. void DoLegalMove(char *);
  174. void DisplayComputerMove(char *);
  175. int HandleEvent(APTR);
  176. void DoAbout(void);
  177. void LoadAGame(void);
  178. void SaveAGame(void);
  179. void ListAGame(void);
  180. void DoQuit(void);
  181. void Go2D(void);
  182. void Go3D(void);
  183. void DoReverse(void);
  184. void DoSwap(void);
  185. void DoAutoPlay(void);
  186. void MoveNow(void);
  187. void TakeBack(void);
  188. void DoThinking(void);
  189. void DoShwThnk(void);
  190. void DoSuper(void);
  191. void DoBookToggle(void);
  192. void DoHint(void);
  193. void DoTest(void);
  194. void SetTime(void);
  195. int GetFileName(char *);
  196.  
  197. void DisplayError(char *);
  198. void __saveds InputThread(void);
  199. void GetOperatorEntry(void);
  200. void AmigaShutDown(void);
  201. void AnimateAmigaMove(char *,char);
  202. void GetTimeString(char *);
  203. void GiveHint(void);
  204. void EditBoard(void);
  205. void help(void);
  206. void ChangeAlphaWindow(void);
  207. void ChangeBetaWindow(void);
  208. void ChangeSearchDepth(void);
  209. void ChangeHashDepth(void);
  210. void SetContempt(void);
  211. void ChangeXwindow(void);
  212. void ShowPostnValues(void);
  213. void DoDebug(void);
  214. void DoTable(INTSIZE *);
  215.  
  216. void GetGame(void);
  217. void SaveGame(void);
  218. void DrawAmigaBoard(void);
  219. void skip(void);
  220. void skipb(void);
  221. void EnPassant (INTSIZE int xside, INTSIZE int f, INTSIZE int t, INTSIZE int iop);
  222.  
  223. void ataks(INTSIZE int, INTSIZE int *);
  224. void Initialize_dist(void);
  225. void InitConst(char *);
  226. int SetAmigaDepth(void);
  227.  
  228.  
  229. #ifdef MSDOS
  230. #include <stdlib.h>
  231. #include <string.h>
  232. #include <time.h>
  233. #define RWA_ACC "r+b"
  234. #define WA_ACC "w+b"
  235. #else
  236. #define RWA_ACC "r+"
  237. #define WA_ACC "w+"
  238. /*
  239. #include <sys/param.h>
  240. #include <sys/types.h>
  241. #include <sys/times.h>
  242. */
  243. #include <stdlib.h>
  244. #include <string.h>
  245. #include <time.h>
  246.  
  247. extern int FirstTime;
  248.  
  249. #endif /* MSDOS */
  250. #ifdef NONDSP
  251. #ifdef AMIGA
  252. #define printz NULLFUNC
  253. #define scanz NULLFUNC2
  254. #else
  255. #define printz printf
  256. #define scanz scanf
  257. #endif
  258. #else
  259. #include <curses.h>
  260. #define scanz fflush(stdout),scanw
  261. #define printz printw
  262. #endif
  263.  
  264. #if defined(__STDC__) || defined(MSDOS)
  265. /* <stdio.h> */
  266.      extern int fclose (FILE *);
  267. #ifndef __ultrix /* work around bug in c89 compiler --t.mann */
  268. #endif /*__ultrix*/
  269.  
  270. /* <stdlib.h> */
  271.  
  272. /* <time.h> */
  273.  
  274. /* <string.h> */
  275. #endif
  276.  
  277.  
  278. /* Piece values */
  279. #define valueP 100
  280. #define valueN 350
  281. #define valueB 355
  282. #define valueR 550
  283. #define valueQ 1100
  284. #define valueK 1200
  285. /* masks into upper 8 bits of ataks array */
  286. #define ctlP 0x4000
  287. #define ctlN 0x2800
  288. #define ctlB 0x1800
  289. #define ctlR 0x0400
  290. #define ctlQ 0x0200
  291. #define ctlK 0x0100
  292. #define ctlBQ 0x1200
  293. #define ctlBN 0x0800
  294. #define ctlRQ 0x0600
  295. #define ctlNN 0x2000
  296. /* attack functions */
  297. #define Patak(c, u) (atak[c][u] > ctlP)
  298. #define Anyatak(c, u) (atak[c][u] > 0)
  299. /* distance function */
  300. #define taxicab(a,b) taxidata[a][b]
  301. /* hashtable flags */
  302. #define truescore 0x0001
  303. #define lowerbound 0x0002
  304. #define upperbound 0x0004
  305. #define kingcastle 0x0008
  306. #define queencastle 0x0010
  307. #define evalflag 0x0020 /* from PL 61 */
  308. /* king positions */
  309. #define wking PieceList[white][0]
  310. #define bking PieceList[black][0]
  311. #define EnemyKing PieceList[c2][0]
  312. /* constants */
  313. /* castle moves */
  314. #define BLACKCASTLE    0x3C3E
  315. #define WHITECASTLE    0x0406
  316. #define LONGBLACKCASTLE    0x3C3A
  317. #define LONGWHITECASTLE    0x0402
  318. /* truth values */
  319. #define false 0
  320. #define true 1
  321. /* colors */
  322. #define white 0
  323. #define black 1
  324. #define neutral 2
  325. /* piece code defines */
  326. #define no_piece 0
  327. #define pawn 1
  328. #define knight 2
  329. #define bishop 3
  330. #define rook 4
  331. #define queen 5
  332. #define king 6
  333. #define bpawn 7
  334. /* node flags */
  335. #define pmask 0x0007
  336. #define promote 0x0008
  337. #define cstlmask 0x0010
  338. #define epmask 0x0020
  339. #define exact 0x0040
  340. #define pwnthrt 0x0080
  341. #define check 0x0100
  342. #define capture 0x0200
  343. #define draw 0x0400
  344. #define book 0x1000
  345. /* move symbols */
  346. #define pxx (CP[2])
  347. #define qxx (CP[1])
  348. #define rxx (CP[4])
  349. #define cxx (CP[3])
  350. /* for everything that can't use the above */
  351. #define Qxx " pnbrqk"
  352. #define Pxx " PNBRQK"
  353. #define Cxx "abcdefgh"
  354. #define Rxx "12345678"
  355. /***************************************************************************/
  356. /***************** Table limits ********************************************/
  357. /*
  358.  * ttblsz must be a power of 2. Setting ttblsz 0 removes the transposition
  359.  * tables.
  360.  */
  361. #ifdef MSDOS
  362. #define vttblsz (1 << 11)
  363. #else
  364. #ifdef _M68040
  365. #define vttblsz (150001) // was 150001 in pl70
  366. #else
  367. #ifndef TINYCHESS
  368. #define vttblsz (1 << 16)
  369. #else
  370. #define vttblsz (1 << 14)
  371. #endif
  372. #endif
  373. #define huge
  374. #endif /* MSODS */
  375.  
  376. #define ttblsz vttblsz
  377. #define TREE 1500        /* max number of tree entries */
  378. #define MAXDEPTH 35        /* max depth a search can be carried */
  379. #define MINDEPTH 2        /* min search depth =1 (no hint), >1 hint */
  380. #define MAXMOVES 400        /* max number of half moves in a game */
  381. #ifdef _M68040
  382. #define BOOKSIZE 30000        /* was 30k Number of unique position/move combinations allowed */
  383. #else
  384. #ifndef TINYCHESS
  385. #define BOOKSIZE 11200        /* was 30k Number of unique position/move combinations allowed */
  386. #else
  387. #define BOOKSIZE 5000        /* was 30k Number of unique position/move combinations allowed */
  388. #endif
  389. #endif
  390. #define CPSIZE 226        /* size of lang file max */
  391. #ifdef _M68040
  392. #define ETABLE (18001)        /* static eval cache was 18001 in uchess pl70 */
  393. #else
  394. #ifndef TINYCHESS
  395. #define ETABLE (2<<11)        /* static eval cache */
  396. #else
  397. #define ETABLE (2<<9)        /* static eval cache */
  398. #endif
  399. #endif
  400. /***************** tuning paramaters **********************************************/
  401. #define MINGAMEIN 4
  402. #define MINMOVES 15
  403. #define FBEYOND 5// was 7
  404. #define SBEYOND 9
  405. #define TBEYOND 11
  406. #define CHKDEPTH 1        /* always look forward CHKDEPTH half-moves if in check */
  407. #define DEPTHBEYOND 11        /* Max to go beyond Sdepth */
  408. #define HASHDEPTH 2 // was 3        /* depth above which to use HashFile */
  409. #define HASHMOVELIMIT 40    /* Use HashFile only for this many moves */
  410. #define PTVALUE 0            /* material value below which pawn threats at 5 & 3 are used */
  411. #define ZDEPTH 3        /* depth beyond which to check ZDELTA for extra time */
  412. #define ZDELTA 40//10        /* is 40 in 4pl68 score delta per ply to cause extra time to be given */
  413. #define QBLOCK false //was true        /* if true cache quiescent positions */
  414. #define BESTDELTA 90
  415. #define ZNODES 1000        /* check the time every ZNODES positions */
  416. /*#define MAXTCCOUNT 4        /* max number of time clicks per search */
  417. #define MAXTCCOUNTX  10        /* max number of time clicks per search to complete ply*/
  418. #define MAXTCCOUNTR 4        /* max number of time clicks per search extensions*/
  419. #define SCORESPLIM 8        /* Score space doesn't apply after this stage */
  420. /*#define MINSEARCHPCT 10        /* must have looked at MINSEARCHPCT moves on a ply on a timeout */
  421. /*#define SCORETIME -50        /* score below which to add search time */
  422. #define SCORESPLIM 8        /* Score space doesn't apply after this stage */
  423. #define SDEPTHLIM Sdepth+2 /* WAS Sdepth+1 in 2.35 of UChess */
  424. #define HISTORYLIM 4096        /* Max value of history killer */
  425. #define EWNDW 10        /* Eval window to force position scoring at depth greater than Sdepth + 2 */
  426. #define WAWNDW 90        /* alpha window when computer white*/
  427. #define WBWNDW 90        /* beta window when computer white*/
  428. #define BAWNDW 90        /* alpha window when computer black*/
  429. #define BBWNDW 90        /* beta window when computer black*/
  430. #define BXWNDW 90        /* window to force position scoring at lower */
  431. #define WXWNDW 90        /* window to force position scoring at lower */
  432. #define PCRASHS    5
  433. #define PCRASHV 5
  434. #define PCENTERS 5
  435. #define PCENTERV 5
  436. #define DITHER 5        /* max amount random can alter a pos value */
  437. #define BBONUS 2        /* points per stage value of B increases */
  438. #define RBONUS 6        /* points per stage value of R increases */
  439. #define KINGPOSLIMIT ( -1)    /* King positional scoring limit */
  440. #define KINGSAFETY  40 /* was 32 in PL60,  in PL61 it is 40 */
  441. #define MAXrehash (7)
  442. #define NULLMOVELIM 4000    /* below this total material on board don't use null move */
  443. #define DEPTHMARGIN 2
  444. #define THRSTAGE    6
  445. #define CHECKSTAGE  5
  446.  
  447. #if defined AG0
  448. #define WHITEAG0
  449. #define BLACKAG0
  450.  
  451. #elif defined AG1
  452. #define WHITEAG1
  453. #define BLACKAG1
  454.  
  455. #elif defined AG2
  456. #define WHITEAG2
  457. #define BLACKAG2
  458.  
  459. #elif defined AG3
  460. #define WHITEAG3
  461. #define BLACKAG3
  462.  
  463. #elif defined AGB
  464. #define WHITEAG2
  465. #define BLACKAG2
  466.  
  467. #elif defined AG4
  468. #define WHITEAG4
  469. #define BLACKAG4
  470. #endif
  471. /************************* parameters for Opening Book *********************************/
  472. #define BOOKBITS 10        /* # bits for hashtable to book moves */
  473. #define BOOKFAIL 20000        /* if no book move found for BOOKFAIL turns stop using book */
  474. #define BOOKRAND 1000        /* used to select an opening move from a list */
  475. #define BOOKENDPCT 950        /* 50 % chance a BOOKEND will stop the book */
  476. #define DONTUSE -32000 //was -32768        /* flag move as don't use */
  477. /*************************** Book access defines ****************************************/
  478. #define BKTBLSIZE (2<<BOOKBITS)
  479. #define BOOKMASK (BKTBLSIZE - 1)
  480. #define SIDEMASK 0x1
  481. #define BOOKEND 0x2        /* means this is the last move of an opening */
  482. #define BADMOVE 0x8000        /* means this is a bad move in this position */
  483. /****************************************************************************************/
  484.      struct hashval
  485.      {
  486.        unsigned long key, bd;
  487.      };
  488.  
  489. #ifdef CACHE
  490.     struct etable
  491.     { unsigned long ehashbd;
  492.         short int escore[2];
  493.         short int sscore[64];
  494.         short int score;
  495.         short int xx_pad;
  496.         short int hung[2];
  497.     } ;
  498.  
  499.  
  500.      struct hashentry
  501.      {
  502.        unsigned long hashbd;
  503.        unsigned short mv;
  504.        unsigned char flags, depth;    /* char saves some space */
  505.        unsigned short age;
  506.        short score;
  507. #ifdef HASHTEST
  508.        unsigned char bd[32];
  509. #endif /* HASHTEST */
  510.  
  511.      };
  512. #else
  513.      struct hashentry
  514.      {
  515.        unsigned long hashbd;
  516.        unsigned INTSIZE2 mv;
  517.        unsigned char flags, depth;    /* char saves some space */
  518.        INTSIZE2 score;
  519. #ifdef HASHTEST
  520.        unsigned char bd[32];
  521. #endif /* HASHTEST */
  522.  
  523.      };
  524. #endif
  525.  
  526. #ifdef HASHFILE
  527.  
  528. /*
  529.  * persistent transposition table. The size must be a power of 2. If you
  530.  * change the size, be sure to run gnuchess -c before anything else.
  531.  */
  532. #define frehash 6
  533. #ifdef MSDOS
  534. #define Deffilesz (1 << 11) -1
  535. #else
  536. #define Deffilesz (1 << 17) -1
  537. #endif /* MSDOS */
  538.      struct fileentry
  539.      {
  540.        unsigned char bd[32];
  541.        unsigned char f, t, flags, depth, sh, sl;
  542.      };
  543.  
  544. #endif /* HASHFILE */
  545.  
  546.  
  547.      struct leaf
  548.      {
  549.        INTSIZE f, t, score, reply, width;
  550.        unsigned INTSIZE flags;
  551.      };
  552.      struct GameRec
  553.      {
  554.        unsigned INTSIZE gmove;    /* this move */
  555.        INTSIZE score;        /* score after this move */
  556.        INTSIZE depth;        /* search depth this move */
  557.        INTSIZE time;        /* search time this move */
  558.        INTSIZE piece;        /* piece captured */
  559.        INTSIZE color;        /* color */
  560.        INTSIZE flags;        /* move flags capture, promote, castle */
  561.        INTSIZE Game50;        /* flag for repetition */
  562.        long nodes;        /* nodes searched for this move */
  563.        long hashkey, hashbd;    /* board key before this move */
  564.        short epssq;        /* epssquare before this move */
  565. #ifdef DEBUG40
  566.        int d1;
  567.        int d2;
  568.        int d3;
  569.        int d4;
  570.        int d5;
  571.        int d6;
  572.        int d7;
  573. #endif
  574.      };
  575.      struct TimeControlRec
  576.      {
  577.        INTSIZE moves[2];
  578.        long clock[2];
  579.      };
  580.  
  581.      struct flags
  582.      {
  583.        INTSIZE mate;        /* the game is over */
  584.        INTSIZE post;        /* show principle variation */
  585.        INTSIZE quit;        /* quit/exit */
  586.        INTSIZE regularstart;    /* did the game start from standard
  587.                  * initial board ? */
  588.        INTSIZE reverse;        /* reverse board display */
  589.        INTSIZE bothsides;        /* computer plays both sides */
  590.        INTSIZE hash;        /* enable/disable transposition table */
  591.        INTSIZE force;        /* enter moves */
  592.        INTSIZE easy;        /* disable thinking on opponents time */
  593.        INTSIZE beep;        /* enable/disable beep */
  594.        INTSIZE timeout;        /* time to make a move */
  595.        INTSIZE musttimeout;    /* time to make a move */
  596.        INTSIZE back;        /* time to make a move */
  597.        INTSIZE rcptr;        /* enable/disable recapture heuristics */
  598.        INTSIZE rv;        /* reverse video */
  599.        INTSIZE stars;        /* add stars to uxdsp screen */
  600.        INTSIZE coords;        /* add coords to visual screen */
  601.        INTSIZE shade;
  602.        INTSIZE material;        /* draw on lack of material */
  603.        INTSIZE illegal;        /* illegal position */
  604.        INTSIZE onemove;        /* timing is onemove */
  605.        INTSIZE gamein;        /* timing is gamein */
  606.        INTSIZE threat;            /* Enable threats, tom@izf.tno.nl */
  607.      };
  608.  
  609. #ifdef DEBUG
  610.      extern FILE *debugfile;
  611.  
  612. #endif /* DEBUG */
  613. #ifdef HISTORY
  614.      extern unsigned char __far history[32768];
  615. #endif
  616.      extern int Sdepth2;
  617.      extern int thinking2;
  618.      extern char *ColorStr[2];
  619.      extern unsigned INTSIZE int MV[MAXDEPTH];
  620.      extern int MSCORE;
  621.      extern int mycnt1, mycnt2;
  622.      extern INTSIZE int ahead;
  623.      extern INTSIZE int chesstool;
  624.      extern struct leaf __far Tree[];
  625.      extern struct leaf  *root/*, rootnode*/;
  626.      extern char __far savefile[];
  627.      extern char __far listfile[];
  628.      extern INTSIZE TrPnt[];
  629.      extern INTSIZE board[], color[];
  630.      extern INTSIZE PieceList[2][64], PawnCnt[2][8];
  631.      extern int Castled[2];
  632.      extern int MouseDropped;
  633.      extern int myEnPassant[2];
  634.      extern INTSIZE castld[], Mvboard[];
  635.      extern INTSIZE __aligned svalue[64];
  636.      extern struct flags flag;
  637.      extern INTSIZE opponent, computer, INCscore;
  638.      extern INTSIZE WAwindow, BAwindow, WBwindow, BBwindow;
  639.      extern INTSIZE dither, player;
  640.      extern INTSIZE xwndw, epsquare, contempt;
  641.      extern long ResponseTime, ExtraTime, MaxResponseTime, et, et0, time0, ft;
  642.      extern long reminus, replus;
  643.      extern long NodeCnt, ETnodes, EvalNodes, HashAdd, HashCnt, HashCol, THashCol,
  644.       FHashCnt, FHashAdd;
  645.      extern INTSIZE HashDepth, HashMoveLimit;
  646.      extern struct GameRec GameList[];
  647.      extern INTSIZE GameCnt, Game50;
  648.      extern INTSIZE Sdepth, MaxSearchDepth;
  649.      extern int Book;
  650.      extern struct TimeControlRec TimeControl;
  651.      extern INTSIZE TCflag, TCmoves, TCminutes, TCseconds, OperatorTime;
  652.      extern int timecomp[MINGAMEIN], timeopp[MINGAMEIN];
  653.      extern int compptr,oppptr;
  654.      extern INTSIZE XCmore, XCmoves[], XCminutes[], XCseconds[], XC;
  655.      extern const INTSIZE otherside[];
  656.      extern const INTSIZE Stboard[];
  657.      extern const INTSIZE Stcolor[];
  658.      extern unsigned INTSIZE hint;
  659.      extern INTSIZE int TOflag;
  660.      extern INTSIZE stage, stage2, Developed[];
  661.      extern INTSIZE ChkFlag[], CptrFlag[], PawnThreat[];
  662.      extern short ChkFlag[], CptrFlag[], PawnThreat[];
  663.      extern short QueenCheck[];  /* tom@izf.tno.nl */
  664. //     extern short NMoves[];  /* tom@izf.tno.nl */
  665.      extern short Threat[];  /* tom@izf.tno.nl */
  666.      extern short ThreatSave[];  /* tom@izf.tno.nl */
  667.      extern INTSIZE Pscore[], Tscore[];
  668.      extern INTSIZE rehash;
  669.      extern unsigned int ttblsize;
  670.      extern INTSIZE mtl[], pmtl[], hung[], emtl[];
  671.      extern INTSIZE Pindex[];
  672.      extern INTSIZE PieceCnt[];
  673.      extern INTSIZE FROMsquare, TOsquare;
  674.      extern INTSIZE HasKnight[], HasBishop[], HasRook[], HasQueen[];
  675.      extern const INTSIZE qrook[];
  676.      extern const INTSIZE krook[];
  677.      extern const INTSIZE kingP[];
  678.      extern const INTSIZE rank7[];
  679.      extern const INTSIZE sweep[];
  680.      extern const INTSIZE epmove1[], epmove2[];
  681.      extern unsigned INTSIZE killr0[], killr1[];
  682.      extern unsigned INTSIZE killr2[], killr3[];
  683.      extern unsigned INTSIZE PV, SwagHt, Swag0, Swag1, Swag2, Swag3, Swag4, sidebit;
  684. #ifdef KILLT
  685.      extern INTSIZE __far __aligned killt[0x4000];
  686. #endif
  687.      extern INTSIZE mtl[2], pmtl[2], hung[2];
  688.      extern const INTSIZE value[];
  689.      extern const INTSIZE control[];
  690.      extern unsigned char __far nextpos[8][64][64];
  691.      extern unsigned char __far nextdir[8][64][64];
  692.      extern const INTSIZE ptype[2][8];
  693.      extern long filesz;
  694.      extern FILE *hashfile;
  695.      extern unsigned int starttime;
  696.      extern int ThinkAheadWorked;
  697.      extern int ThinkInARow;
  698.      extern int ThinkAheadDepth;
  699. #ifdef LONGINTS2
  700.      extern INTSIZE __far distdata[64][64];
  701.      extern INTSIZE __far taxidata[64][64];
  702. #else
  703.      extern INTSIZE distdata[64][64];
  704.      extern INTSIZE taxidata[64][64];
  705. #endif
  706.      extern int bookcount;
  707.      extern unsigned long hashkey, hashbd;
  708. #ifdef LONGINTS2
  709.      extern struct hashval __far hashcode[2][7][64];
  710. #else
  711.      extern struct hashval hashcode[2][7][64];
  712. #endif
  713.      extern char __far *CP[];
  714. #ifdef QUIETBACKGROUND
  715.      extern INTSIZE background;
  716. #endif /* QUIETBACKGROUND */
  717.  
  718. #ifdef CACHE
  719.  
  720. #ifdef ttblsz
  721.      extern struct hashentry *ttable[2];
  722. #endif
  723.  
  724. #else
  725.  
  726. #ifdef ttblsz
  727.      extern struct hashentry __far ttable[2][vttblsz + MAXrehash];
  728. #endif
  729.  
  730. #endif
  731.  
  732. /*
  733.  * hashbd contains a 32 bit "signature" of the board position. hashkey
  734.  * contains a 16 bit code used to address the hash table. When a move is
  735.  * made, XOR'ing the hashcode of moved piece on the from and to squares with
  736.  * the hashbd and hashkey values keeps things current.
  737.  */
  738. #define UpdateHashbd(side, piece, f, t) \
  739. {\
  740.   if ((f) >= 0)\
  741.     {\
  742.       hashbd ^= hashcode[side][piece][f].bd;\
  743.       hashkey ^= hashcode[side][piece][f].key;\
  744.     }\
  745.   if ((t) >= 0)\
  746.     {\
  747.       hashbd ^= hashcode[side][piece][t].bd;\
  748.       hashkey ^= hashcode[side][piece][t].key;\
  749.     }\
  750. }
  751.  
  752.  
  753.      extern INTSIZE rpthash[2][256];
  754.      extern char *DRAW;
  755.  
  756. #define distance(a,b) distdata[a][b]
  757. #define row(a) ((a) >> 3)
  758. #define column(a) ((a) & 7)
  759. #define locn(a,b) (((a) << 3) | (b))
  760.  
  761. /* init external functions */
  762.      extern void NewGame (void);
  763.      extern int parse (FILE * fd, INTSIZE unsigned int *mv, INTSIZE int side, char *opening);
  764.      extern void GetOpenings (int);
  765.      extern int OpeningBook (unsigned INTSIZE int *hint, INTSIZE int side);
  766.      extern void SelectMove (INTSIZE int side, INTSIZE int iop);
  767.      int 
  768.       search (INTSIZE int side,
  769.            INTSIZE int ply,
  770.            INTSIZE int depth,
  771.            short ext,
  772.            INTSIZE int alpha,
  773.            INTSIZE int beta,
  774.            INTSIZE unsigned int *bstline,
  775.            INTSIZE int *rpt,
  776.                short SAVEHT,
  777.            int didnull);
  778. #if ttblsz
  779.      extern int
  780.       ProbeTTable (int side,
  781.             int depth,
  782.             int ply,
  783.             SHORT *alpha,
  784.             SHORT *beta,
  785.             SHORT *score);
  786.      extern int
  787.       PutInTTable (int side,
  788.             int score,
  789.             int depth,
  790.             int ply,
  791.             //int alpha,
  792.             int beta,
  793.             unsigned int mv);
  794.      extern void ZeroTTable (int);
  795.      extern void ZeroRPT (void);
  796.      extern void Initialize_ttable (void);
  797. #ifdef HASHFILE
  798.      extern unsigned int urand (void);
  799.      extern void srand (unsigned int);
  800.      extern int
  801.       ProbeFTable (INTSIZE int side,
  802.             INTSIZE int depth,
  803.             INTSIZE int ply,
  804.             INTSIZE int *alpha,
  805.             INTSIZE int *beta,
  806.             INTSIZE int *score);
  807.      extern void
  808.       PutInFTable (INTSIZE int side,
  809.             INTSIZE int score,
  810.             INTSIZE int depth,
  811.             INTSIZE int ply,
  812.             INTSIZE int alpha,
  813.             INTSIZE int beta,
  814.             INTSIZE unsigned int f,
  815.             INTSIZE unsigned int t);
  816.  
  817. #endif /* HASHFILE */
  818. #endif /* ttblsz */
  819.      extern void Initialize_moves (void);
  820.      extern void MoveList (INTSIZE int side, INTSIZE int ply);
  821.      extern void CaptureList (INTSIZE int side, INTSIZE int ply);
  822.      extern int castle (INTSIZE int side, INTSIZE int kf, INTSIZE int kt, INTSIZE int iop);
  823.      extern void
  824.       MakeMove (INTSIZE int side,
  825.          struct leaf * node,
  826.          INTSIZE int *tempb,
  827.          INTSIZE int *tempc,
  828.          INTSIZE int *tempsf,
  829.          INTSIZE int *tempst,
  830.          INTSIZE int *INCscore);
  831.      extern void
  832.       UnmakeMove (INTSIZE int side,
  833.            struct leaf * node,
  834.            INTSIZE int *tempb,
  835.            INTSIZE int *tempc,
  836.            INTSIZE int *tempsf,
  837.            INTSIZE int *tempst);
  838.      extern void InitializeStats (void);
  839. #ifdef OLD4PL67
  840.      extern int
  841.       evaluate (INTSIZE int side,
  842.          INTSIZE int ply,
  843.          INTSIZE int alpha,
  844.          INTSIZE int beta,
  845.          INTSIZE int INCscore,
  846.          /*INTSIZE int *slk,*/
  847.          INTSIZE int *InChk);
  848. #else
  849. int
  850. evaluate (register short side,
  851.       register short ply,
  852.       register short depth,
  853.           register short ext,
  854.       register short alpha,
  855.       register short beta,
  856.       short INCscore,
  857.       short *InChk);    /* output Check flag */
  858. #endif
  859.      extern INTSIZE int ScorePosition (INTSIZE int side);
  860.      extern void ExaminePosition (void);
  861.      extern void Initialize (void);
  862.      extern void InputCommand (char *);
  863.      extern void ExitChess (void);
  864.      extern void ClrScreen (void);
  865.      extern void SetTimeControl (void);
  866.      extern void SelectLevel (char *);
  867.      extern void
  868.       UpdateDisplay (INTSIZE int f,
  869.               INTSIZE int t,
  870.               INTSIZE int flag,
  871.               INTSIZE int iscastle);
  872.      extern void ElapsedTime (INTSIZE int iop);
  873.      extern void ShowSidetoMove (void);
  874.      extern void SearchStartStuff (INTSIZE int side);
  875.      extern void ShowDepth (char ch);
  876.      extern void TerminateSearch (int);
  877.      extern void
  878.       ShowResults (INTSIZE int score,
  879.             INTSIZE unsigned int *bstline,
  880.             char ch);
  881.      extern void PromptForMove (void);
  882.      extern void SetupBoard (void);
  883.      extern void algbr (INTSIZE int f, INTSIZE int t, INTSIZE int flag);
  884.      extern void OutputMove (char *);
  885.      extern void ShowCurrentMove (INTSIZE int pnt, INTSIZE int f, INTSIZE int t);
  886.      extern void ListGame (int);
  887.      extern void ShowMessage (char *s);
  888.      extern void ClrScreen (void);
  889.      extern void gotoXY (INTSIZE int x, INTSIZE int y);
  890.      extern void ClrEoln (void);
  891.      extern void DrawPiece (INTSIZE int sq);
  892.      extern void UpdateClocks (void);
  893.      extern void ShowLine (INTSIZE unsigned int *bstline,char *);
  894.      extern int pick (INTSIZE int p1, INTSIZE int p2);
  895.      extern int TrComp (struct leaf * a, struct leaf * b);
  896.      void UpdateWeights(void);
  897.  
  898. #ifdef AMIGA
  899. struct myMsgStruct {
  900. struct Message MainMsg;
  901. ULONG myData;
  902. };
  903. #endif
  904.  
  905.  
  906.  
  907. #include "ttable.h"
  908.